<!--
  管理页面主页
-->
<template>
    <van-notice-bar v-show="user.userRole === 'admin'" mode="closeable">管理员你好,欢迎进入管理页面</van-notice-bar>
    <van-notice-bar v-show="user.userRole === 'superAdmin'" mode="closeable">超级管理员你好,欢迎进入管理页面</van-notice-bar>
    <van-notice-bar mode="closeable">请选择模块一个进入</van-notice-bar>
    <van-field
            v-model="fieldText"
            is-link
            readonly
            label="选项"
            placeholder="选择管理模块"
            @click="showPicker = true"
    />
    <van-popup v-model:show="showPicker" round position="bottom">
        <van-picker
                :columns="columns"
                @cancel="showPicker = false"
                @confirm="onConfirm"
        />
    </van-popup>
    <van-cell-group v-show="fieldValue === 'user'">
        <van-cell title=""></van-cell>
        <van-cell title="用户管理模块功能简述" size="large"></van-cell>
        <van-cell title="1.用户信息状态查看"></van-cell>
        <van-cell title="2.用户信息修改"></van-cell>
        <van-cell title="3.用户签到状态查询与分析"></van-cell>
        <van-cell title="4.单独新增用户"></van-cell>
        <van-cell title="5.批量新增用户"></van-cell>
        <van-cell title=""></van-cell>
    </van-cell-group>
    <van-cell-group v-show="fieldValue === 'dept'">
        <van-cell title=""></van-cell>
        <van-cell title="签到管理模块功能简述" size="large"></van-cell>
        <van-cell title="1.修改公司信息"></van-cell>
        <van-cell title="2.修改签退签到时间"></van-cell>
        <van-cell title="3.修改签到gps定位信息"></van-cell>
        <van-cell title=""></van-cell>
    </van-cell-group>
    <van-button type="primary" class="parent-container" size="large" @click="clickEnter()">进入页面</van-button>
</template>

<script setup>
import {useRouter} from "vue-router";
import {computed, onMounted, ref} from "vue";
import myAxios from "../../plugins/myAxios";
import {showDialog, showFailToast, showSuccessToast, showToast} from "vant";
import {getCurrentUser} from "../services/user";
import UserAddPage from "./UserAddPage.vue";
import {getUserRoleIsAdmin} from "../services/userRole.ts";

const user = ref('');
const router = useRouter();
const active = ref(0);

onMounted(async () => {
    fieldText.value = "用户管理";
    fieldValue.value = "user";
    const res = await getCurrentUser();
    user.value = res.data;
    // console.log(user.value.userRole === 'admin')
    await getUserRoleIsAdmin();

})

const columns = [
    { text: '用户管理', value: 'user' },
    { text: '公司管理', value: 'dept' }
];
const fieldValue = ref('');
const fieldText = ref('');
const showPicker = ref(false);
const onConfirm = ({ selectedOptions }) => {
    showPicker.value = false;
    fieldText.value = selectedOptions[0].text;
    fieldValue.value = selectedOptions[0].value;
};
const clickEnter =  async () =>{
    if (fieldValue.value === 'user'){
        await router.push({
            path: '/admin/user/list',
            replace: true,
        });
    }else if (fieldValue.value === 'dept'){
        await router.push({
            path: '/admin/deptInfo',
            replace: true,
        });
    }
}

</script>

<style scoped>


</style>